<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计数器小案例</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <h2>当前计数：{{counter}}</h2>
        <button @click='Numadd'>+</button>
        <button @click='Numsub'>-</button>
    </div>
    <script>
        const obj = {
            counter: 0
        }
        let app = new Vue({
            el: '#app',
            data: obj,
            methods: {
                // ()中可以传参
                Numadd() {
                    this.counter++
                    console.log('counter++');
                },
                Numsub() {
                    this.counter--;
                    console.log('counter--');
                }
            }
        })
    </script>
</body>

</html>